package com.burgeon.backend.SHOP.controller;

import com.burgeon.backend.SHOP.entity.PayData;
import com.burgeon.backend.SHOP.service.PlusActiveService;
import com.burgeon.backend.stsutil.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.HashMap;

@RestController
@RequestMapping("shop/plus")
public class PlusActiveController extends BaseController {
    @Autowired
    private PlusActiveService plusActiveService;

    //plus会员页面数据展示
    @RequestMapping("getData")
    private ResponseResult<HashMap> getData(HttpSession session){
        System.err.println("session===="+session);
        String token = session.getAttribute("token").toString();
        String uid = session.getAttribute("uid").toString();
        HashMap data = plusActiveService.getData(token,uid);
        return new ResponseResult<HashMap>(SUCCESS,data);
    }

    //开通plus会员
    @RequestMapping("openPlus")
    private ResponseResult<PayData> openPlus(HttpSession session, String total_fee) throws Exception {
        String token = session.getAttribute("token").toString();
        String uid = session.getAttribute("uid").toString();
        String openid = session.getAttribute("app_openid").toString();
        PayData data = plusActiveService.openPlus(token,uid,openid,total_fee);
        return new ResponseResult<PayData>(SUCCESS,data);
    }



}
